home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
LIBRARY
/
DOTPLOT.LI3
< prev
next >
Wrap
Text File
|
1993-12-23
|
851b
|
32 lines
# dotplot() plots dot curve of y=f(x) on xy-plane
# by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
# e.g. dotplot(x^3,x)
dotplot(y_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
graph,
getmaxy3:=getmaxy-30,
getmaxy1:=getmaxy3+1,
dx:=(xmax-xmin)/(getmaxx-40),
dy:=(ymax-ymin)/getmaxy3,
xstep:=dx*10,
line(40,getmaxy3,getmaxx,getmaxy3),
line(40,0,40,getmaxy3),
moveto(0,0),
writes(ymax),
moveto(0,getmaxy3),
writes(ymin),
moveto(40,getmaxy-20),
writes(xmin),
moveto(getmaxx-30,getmaxy-20),
writes(xmax),
setviewport(40,0,getmaxx,getmaxy3,1),
moveto(0,getmaxy3),
do( putpixel((x-xmin)/dx,getmaxy1-(y-ymin)/dy,15),
x,xmin,xmax,xstep),
numeric:=off,
readchar,
text,
local(dx,dy,xstep))
dotplot(y_, x_, xmin_, xmax_) := dotplot(y,x,xmin,xmax,-5,5)
dotplot(y_, x_) := dotplot(y,x,-5,5,-5,5)